//
//  MM_HomeDataStatisticsVC.m
//  MallManage_IOS
//
//  Created by 张浩 on 2023/9/20.
//

#import "MM_HomeDataStatisticsVC.h"

@interface MM_HomeDataStatisticsVC ()

@property (nonatomic, strong) UILabel *numberLabel;
@property (nonatomic, strong) UILabel *descLabel;

@end

@implementation MM_HomeDataStatisticsVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.titleView.title = @"数据统计";
//    self.titleView.hidden = YES;
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self.view addSubview:self.numberLabel];
    [self.view addSubview:self.descLabel];
    
    [self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(NaviBarHeight + 40);
        make.centerX.equalTo(self.view);
    }];
    
    [self.descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.numberLabel.mas_bottom).offset(80);
        make.centerX.equalTo(self.view);
    }];
    
    [self loadData];
}

- (void)loadData {
    
    NSMutableDictionary *parmDic = [NSMutableDictionary dictionary];
    
    [self showHudInView:self.view hint:@"加载中"];
    [MM_Http postRequestURLStr:KMM_Stock_Statistics withDic:parmDic success:^(NSDictionary * _Nonnull requestDic, NSString * _Nonnull msg) {
        [self hideHud];
        
        NSString *cost_total = [requestDic[@"cost_total"] description];
        NSString *count_total = [requestDic[@"count_total"] description];
        NSString *price_total = [requestDic[@"price_total"] description];
        NSString *statistics_time = [requestDic[@"statistics_time"] description];
        
        self.numberLabel.text = [NSString stringWithFormat:@"出售总数量: %@\n出售总成本: %@\n出售总价格: %@",count_total,cost_total,price_total];
        self.descLabel.text = [NSString stringWithFormat:@"数据截止到: %@",statistics_time];
        
        NSLog(@"requestDicrequestDicrequestDic == %@",requestDic);
        
    } failure:^(NSString * _Nonnull errorInfo, NSString * _Nonnull status) {
        [self hideHud];
        [self showStateText:errorInfo];
    }];
}
 
- (UILabel *)numberLabel {
    
    if (_numberLabel == nil) {
        
        _numberLabel = [Custom_ZHTool uiLabelCreate:@"" Font:FONT(16) TextColor:MM_ColorUtil(@"#333333")];
        _numberLabel.textAlignment = NSTextAlignmentCenter;
        _numberLabel.numberOfLines = 0;
        
//        _numberLabel.text = [NSString stringWithFormat:@"出售总数量: 99999\n出售总成本: 33333\n出售总价格: 99999"];
        [_numberLabel changeLineSpace:13];
    }
    return _numberLabel;
}

- (UILabel *)descLabel {
    
    if (_descLabel == nil) {
        
        _descLabel = [Custom_ZHTool uiLabelCreate:@"" Font:FONT(16) TextColor:MM_ColorUtil(@"#DC1818")];
        _descLabel.textAlignment = NSTextAlignmentCenter;

    }
    return _descLabel;
}
@end
